﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace de.codingfreaks.libs.cfThreadingTools.Extensions
{
    /// <summary>
    /// Provides extensions for <c>System.Windows.Forms.Control and subsequent objects.</c>
    /// </summary>
    public static class ControlExensions
    {

        /// <summary>
        /// Sets the Enabled-property of a control to true.
        /// </summary>
        /// <param name="ctlTarget">The control for extensions-purposes.</param>
        public static void EnableThreadSafe(this Control ctlTarget)
        {
            BaseTools.SetPropertyValue(ctlTarget, "Enabled", true);
        }

        /// <summary>
        /// Sets the Enabled-property of a control to false.
        /// </summary>
        /// <param name="ctlTarget">The control for extensions-purposes.</param>
        public static void DisableThreadSafe(this Control ctlTarget)
        {
            BaseTools.SetPropertyValue(ctlTarget, "Enabled", false);
        }

        /// <summary>
        /// Calls the Hide-method thread-safe.
        /// </summary>
        /// <param name="ctlTarget">The control to hide.</param>
        public static void HideThreadSafe(this Control ctlTarget)
        {
            BaseTools.InvokeMethod(ctlTarget, "Hide");
        }

    }
}
